package com.czxy.Demo19;


public class BankCard {
    private double balance; //  余额

    public BankCard(double balance) {
        this.balance = balance;
    }

    public BankCard() {
    }

    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }

    public void drawMoney(double money) throws BankException {
        if (money > balance){
            BankException b =  new BankException();
            b.show1();
            throw new BankException();
        }else{
            balance-=money;
            System.out.println("取出"+money+"还剩"+balance);
        }
    }

    public double saveMoney(double money) throws BankException {
        if (money > 5000){
            BankException b = new BankException();
            b.show2();
            throw new BankException();
        }else {
            return balance+=money;
        }
    }

}